package com.demo.ping.service.impl;

import com.demo.ping.service.KafkaService;
import jakarta.annotation.Resource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

/**
 *  @author Jofo
 */
@Service
public class KafkaServiceImpl implements KafkaService {
    @Resource
    private KafkaTemplate<String, String> kafkaTemplate;

    @Value("${spring.kafka.topic}")
    private String topic;

    /**
     * Send a message to a specified Kafka topic
     *
     * @param key of the message
     * @param message to send the content of the message
     */
    @Override
    public void sendMessage(String key,String message) {
        kafkaTemplate.send(topic, key,message);
    }
}
